
$(function () {
	initPlanTask = 1;
	initPlanTaskData();
});

//界面数据初始化
function initPlanTaskData() {
	//请求参数
	var obj = {
		budgetYear: fullYear,
		budgetMonth: fullMonth,
		dept: fullDepartment,
		status: 2,
		chartPage: '31'
	}
	//API
	ApiGet('getdata', obj, function (e) {

		var json = JSON.parse(e);
		var chartData = json.items[0].charts;
		setPanel(chartData)
		getCJplan(chartData)
		getCJplanRate(chartData)
		getXMplan(chartData)
		getMonPlanComplete(chartData)
		getMonPlanCompletee(chartData)
	});
}

//设置面板
function setPanel(data) {
	let alldata = data;



	if (alldata[4]['data'][0]['key01'] == "" || alldata[4]['data'][0]['key01'] == null || alldata[4]['data'][0]['key01'] == undefined) {
		alldata[4]['data'][0]['key01'] = 0
	}
	if (alldata[4]['data'][0]['key02'] == "" || alldata[4]['data'][0]['key02'] == null || alldata[4]['data'][0]['key02'] == undefined) {
		alldata[4]['data'][0]['key02'] = '-'
	}
	if (alldata[4]['data'][0]['key03'] == "" || alldata[4]['data'][0]['key03'] == null || alldata[4]['data'][0]['key03'] == undefined) {
		alldata[4]['data'][0]['key03'] = '-'
	}
	if (alldata[4]['data'][0]['key04'] == "" || alldata[4]['data'][0]['key04'] == null || alldata[4]['data'][0]['key04'] == undefined) {
		alldata[4]['data'][0]['key04'] = 0
	}




	if (alldata[5]['data'][0]['key01'] == "" || alldata[5]['data'][0]['key01'] == null || alldata[5]['data'][0]['key01'] == undefined) {
		alldata[5]['data'][0]['key01'] = 0
	}
	if (alldata[5]['data'][0]['key02'] == "" || alldata[5]['data'][0]['key02'] == null || alldata[5]['data'][0]['key02'] == undefined) {
		alldata[5]['data'][0]['key02'] = '-'
	}
	if (alldata[5]['data'][0]['key03'] == "" || alldata[5]['data'][0]['key03'] == null || alldata[5]['data'][0]['key03'] == undefined) {
		alldata[5]['data'][0]['key03'] = '-'
	}
	if (alldata[5]['data'][0]['key04'] == "" || alldata[5]['data'][0]['key04'] == null || alldata[5]['data'][0]['key04'] == undefined) {
		alldata[5]['data'][0]['key04'] = 0
	}



	if (alldata[6]['data'][0]['key01'] == "" || alldata[6]['data'][0]['key01'] == null || alldata[6]['data'][0]['key01'] == undefined) {
		alldata[6]['data'][0]['key01'] = 0
	}
	if (alldata[6]['data'][0]['key02'] == "" || alldata[6]['data'][0]['key02'] == null || alldata[6]['data'][0]['key02'] == undefined) {
		alldata[6]['data'][0]['key02'] = '-'
	}
	if (alldata[6]['data'][0]['key03'] == "" || alldata[6]['data'][0]['key03'] == null || alldata[6]['data'][0]['key03'] == undefined) {
		alldata[6]['data'][0]['key03'] = '-'
	}
	if (alldata[6]['data'][0]['key04'] == "" || alldata[6]['data'][0]['key04'] == null || alldata[6]['data'][0]['key04'] == undefined) {
		alldata[6]['data'][0]['key04'] = 0
	}






	$(".lione").text(alldata[4]['data'][0]['key01']);
	$(".litwo").text(alldata[4]['data'][0]['key02']);
	$(".lithree").text(alldata[4]['data'][0]['key03']);

	$(".lione2").text(alldata[5]['data'][0]['key01']);
	$(".litwo2").text(alldata[5]['data'][0]['key02']);
	$(".lithree2").text(alldata[5]['data'][0]['key03']);

	$(".lione3").text(alldata[6]['data'][0]['key01']);
	$(".litwo3").text(alldata[6]['data'][0]['key02']);
	$(".lithree3").text(alldata[6]['data'][0]['key03']);


	//获取具体的数据
	let lione = $(".lione").text();
	let lione2 = $(".lione2").text();
	let lione3 = $(".lione3").text();

	let litwo = $(".litwo").text();
	let litwo2 = $(".litwo2").text();
	let litwo3 = $(".litwo3").text();

	let lithree = $(".lithree").text();
	let lithree2 = $(".lithree2").text();
	let lithree3 = $(".lithree3").text();


	//总体计划完成率
	let lionei = alldata[4]['data'][0]['key04'];
	let lioneii = lionei * 100;
	let lioneiii = 1 - lionei;

	lioneiiii = 100 * lioneiii.toFixed(3);

	$('circle').eq(1).attr('stroke-dasharray', lionei * 216 + ' 216')

	if (lionei === 0) {
		$('circle').eq(1).css("display", "none")
	}

	if (lionei !== 0) {
		$('circle').eq(1).css("display", "block")
	}

	$(".prcentnumleft").html(lioneii + '<span>%</span>');
	$(".prcentnumright").html(lioneiiii + '<span>%</span>');
	////////////////////////////////////////////////////////////
	//如果总体计划的完成率是100%
	if (lione == lithree) {

		$(".lispecial").css("display", "none")
		$(".prcentnumleft").css("display", "none")
		$(".prcentnumright").css("display", "none")
		$(".prcentnumok").css("display", "block")
	}


	//车间任务完成率
	// console.log(alldata[3]['data']);
	let lioneo = alldata[5]['data'][0]['key04'];

	let lioneoo = lioneo * 100;
	let lioneooo = 1 - lioneo;

	lioneoooo = 100 * lioneooo.toFixed(3);
	$('circle').eq(3).attr('stroke-dasharray', lioneo * 216 + ' 216')

	if (lioneo === 0) {
		$('circle').eq(3).css("display", "none")
	}

	if (lioneo !== 0) {
		$('circle').eq(3).css("display", "block")
	}

	$(".prcentnumleft2").html(lioneoo + '<span>%</span>');
	$(".prcentnumright2").html(lioneoooo + '<span>%</span>');
	/////////////////////////////////////////////////////////////
	//如果车间任务的完成率是100%
	if (lione2 == lithree2) {

		// $(".lispecial2").css("display","none")
		$(".prcentnumleft2").css("display", "none")
		$(".prcentnumright2").css("display", "none")
		$(".prcentnumok2").css("display", "block")
	}


	//型号任务完成率
	let lionep = alldata[6]['data'][0]['key04'];
	let lionepp = lionep * 100;
	let lioneppp = 1 - lionep;

	lionepppp = 100 * lioneppp.toFixed(3);



	$('circle').eq(5).attr('stroke-dasharray', lionep * 216 + ' 216')

	if (lionep === 0) {
		$('circle').eq(5).css("display", "none")
	}

	if (lionep !== 0) {
		$('circle').eq(5).css("display", "block")
	}

	$(".prcentnumleft3").html(lionepp + '<span>%</span>');
	$(".prcentnumright3").html(lionepppp + '<span>%</span>');
	/////////////////////////////////////////////////////////////
	//如果型号任务的完成率是100%
	if (lione3 == lithree3) {

		$(".lispecial3").css("display", "none")
		$(".prcentnumleft2").css("display", "none")
		$(".prcentnumright2").css("display", "none")
		$(".prcentnumok3").css("display", "block")
	}
}

//各车间计划完成情况
function getCJplan(data) {
	let alldata = data;

	let thisdata = alldata[2]['data'];

	var xarray = [];
	var yarray = [];
	var thismonth = alldata[9].data[0].key01 * 100;
	var rate = alldata[9].data[0].key02 * 100;

	for (let i = 0; i < thisdata.length; i++) {
		xarray.push(thisdata[i]['key01'])
		yarray.push(thisdata[i]['key02'] * 100)
	}

	////////////////月度计划完成率///////////////////////
	var chartDom = document.getElementById('monthlycompletionprecent');
	var myChart = echarts.init(chartDom);
	var option;
	let image;
	let imageColor;
	if (rate == 0) {
		image = 'assets/images/home/icon-pingjun@2x.png';
		imageColor = '#165DFF';
	} else if (rate < 0) {
		image = 'assets/images/home/arrow-down-filling.svg';
		imageColor = '#F53F3F'
	} else {
		image = 'assets/images/home/arrow-up-filling.svg';
		imageColor = '#00B42A'
	}

	option = {
		grid: {
			show: false,
			top: "50px",
			left: "30px",
			right: "10px",
			bottom: "43px"
		},
		tooltip: {
			show: true,
			trigger: 'axis',
			formatter: function (params) {

				for (var i = 0; i < params.length; i++) {

					var res = "<div style='margin-left:0px;margin-bottom:7px;padding:0;width:120px;height:24px;line-height:10px;border-radius:3px;font-size: 12px;font-weight: 500;color: #1D2129;'><p style='font-weight:500;'>"
						+ params[0]['axisValue'] +
						"月</p></div>" +
						"<div style='display: flex; flex-direction: row; align-items: center; justify-content: space-between; margin-top:-10px; width:160px; background:white; height:30px;border-radius: 4px 4px 4px 4px; color: #fff;font-size: 14px; padding:0 12px;line-height: 10px'>" +
						"<div><span style='display:inline-block; border-radius:5px;   width:10px;height:10px;background-color:#165DFF;color:#1D2129;'></span>" +
						"<span style='margin-left:5px; font-size: 12px; font-family: PingFang SC-Regular, PingFang SC; font-weight: 400; color: #4E5969;'>完成率</span></div>" +
						"<span style='font-size: 12px;font-family: PingFang SC-Regular, PingFang SC;font-weight: 400;color: #4E5969;'><span style='font-size: 14px; font-family: Helvetica Neue-Medium, Helvetica Neue; font-weight: 500; color: #1D2129;'>"
						+ params[0]['data'] + "</span>%</span></div>"
				}
				return res;

			},
			axisPointer: {
				type: 'line',
				lineStyle: {
					type: 'solid'
				}
			},
			backgroundColor: "rgb(239, 242, 245,0.95)",
			borderColor: "rgb(239, 242, 245,0.95)",
			textStyle: {
				backgroundColor: 'red'
			},
		},
		xAxis: {
			type: 'category',
			data: xarray,
			name: '',
			"axisTick": {       //y轴刻度线
				"show": false,
			},
			boundaryGap: false, // 不留白，从原点开始
			axisLine: {
				lineStyle: {
					color: '#a4a7aa'
				}
			}
		},
		yAxis: {
			// type: 'value',
			name: '%',
			"axisTick": {       //y轴刻度线
				"show": false
			},
			splitLine: {
				lineStyle: {
					type: 'dashed'//虚线
				},
				show: true //隐藏
			}
		},
		series: [
			{
				data: yarray,
				type: 'line',
				areaStyle: {
					color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
						{
							offset: 0,
							color: '#93b3ff'
						},
						{
							offset: 1,
							color: 'white'
						}
					])
				},
				showSymbol: false,//是否默认展示圆点
				symbol: 'circle',     //设定为实心点
				symbolSize: 9,   //设定实心点的大小
				smooth: true,

				itemStyle: {
					normal: {
						color: "#165DFF", //改变折线点的颜色
						borderColor: 'white',
						borderWidth: 2,
						lineStyle: {
							color: "#165DFF", //改变折线颜色
						},

						tooltip: {
							trigger: 'axis',
							axisPointer: {
								type: 'cross',
								label: {
									backgroundColor: 'red'
								}
							},
							backgroundColor: "rgb(151, 151, 151,0.1)",
							borderColor: "rgb(151, 151, 151,0.1)",
						}

					},
				},

			}
		]
	};

	option && myChart.setOption(option);
}

//各车间占比
function getCJplanRate(data) {
	let alldata = data;
	// console.log(alldata, '123');
	// console.log(alldata[5].data,'456');
	let thisdata = alldata[7].data
	var xarray = [];
	var donearray = [];
	var nodonearray = [];
	for (let i = 0; i < thisdata.length; i++) {
		// console.log(thisdata[i])
		xarray.push(thisdata[i]['key01'])
		donearray.push(thisdata[i]['key02'])
		nodonearray.push(thisdata[i]['key03'])
	}
	// console.log(xarray);
	// console.log(donearray);
	// console.log(nodonearray);
	/////////////////各车间完成数////////////////////
	var app = {};

	var chartDom = document.getElementById('completedworkshop');
	var myChart = echarts.init(chartDom);
	var option;

	const posList = [
		'left',
		'right',
		'top',
		'bottom',
		'inside',
		'insideTop',
		'insideLeft',
		'insideRight',
		'insideBottom',
		'insideTopLeft',
		'insideTopRight',
		'insideBottomLeft',
		'insideBottomRight'
	];
	app.configParameters = {
		rotate: {
			min: -90,
			max: 90
		},
		align: {
			options: {
				left: 'left',
				center: 'center',
				right: 'right'
			}
		},
		verticalAlign: {
			options: {
				top: 'top',
				middle: 'middle',
				bottom: 'bottom'
			}
		},
		position: {
			options: posList.reduce(function (map, pos) {
				map[pos] = pos;
				return map;
			}, {})
		},
		distance: {
			min: 0,
			max: 100
		}
	};
	app.config = {
		rotate: 90,
		align: 'left',
		verticalAlign: 'middle',
		position: 'insideBottom',
		distance: 15,
		onChange: function () {
			const labelOption = {
				rotate: app.config.rotate,
				align: app.config.align,
				verticalAlign: app.config.verticalAlign,
				position: app.config.position,
				distance: app.config.distance
			};
			myChart.setOption({
				series: [
					{
						label: labelOption
					},
					{
						label: labelOption
					},
					{
						label: labelOption
					},
					{
						label: labelOption
					}
				]
			});
		}
	};
	const labelOption = {
		position: app.config.position,
		distance: app.config.distance,
		align: app.config.align,
		verticalAlign: app.config.verticalAlign,
		rotate: app.config.rotate,
		formatter: '{c}  {name|{a}}',
		fontSize: 14,
		rich: {
			name: {}
		}
	};
	option = {

		grid: {
			show: false,
			top: "50px",
			left: "30px",
			right: "10px",
			bottom: "43px"
		},

		tooltip: {
			show: true,
			trigger: 'axis',
			// formatter: '{b0}月<br>完成率：{c0}%',
			formatter: function (params) {
				// console.log('asdasd',params[0])
				// console.log('fghfgh',params[1])

				// var res = 

				//   "<div style='margin-bottom:5px;padding:0 12px;width:100%;height:24px;line-height:24px;background:pink;border-radius:3px;'><p>" +
				//   xarray[i] +
				//   " </p></div>";
				for (var i = 0; i < params.length; i++) {
					//    console.log('bbbbbbbbbbbbb',params[0])
					var res = "<div style='margin-left:0px;margin-bottom:7px;padding:0;height:24px;line-height:10px;border-radius:3px;font-size: 12px;font-weight: 500;color: #1D2129;'><p style='font-weight:500;'>"
						+ params[0]['axisValue'] +
						"</p></div>" +

						"<div style='display: flex; flex-direction: row; align-items: center; justify-content: space-between; margin-top:-10px; width:160px; background:white; height:30px;border-radius: 4px 4px 4px 4px; color: #fff;font-size: 14px; padding:0 12px;line-height: 10px'>" +
						"<div><span style='display:inline-block; border-radius:5px;   width:10px;height:10px;background-color:#165DFF;color:#1D2129;]};'></span>" +
						"<span style='margin-left:5px; font-size: 12px; font-family: PingFang SC-Regular, PingFang SC; font-weight: 400; color: #4E5969;'>"
						+ params[0]['seriesName'] + "数</span></div>" +
						"<span style='font-size: 12px;font-family: PingFang SC-Regular, PingFang SC;font-weight: 400;color: #4E5969;'><span style='font-size: 14px; font-family: Helvetica Neue-Medium, Helvetica Neue; font-weight: 500; color: #1D2129;'><span style='font-size: 14px; font-family: Helvetica Neue-Medium, Helvetica Neue; font-weight: 500; color: #1D2129;'>"
						+ params[0]['data'] + "</span>个</span></div>" +

						"<div style='display: flex; flex-direction: row; align-items: center; justify-content: space-between; margin-top:10px; width:160px; background:white; height:30px;border-radius: 4px 4px 4px 4px; color: #fff;font-size: 14px; padding:0 12px;line-height: 10px'>" +
						"<div><span style='display:inline-block; border-radius:5px;   width:10px;height:10px;background-color:#F53F3F;color:#1D2129;]};'></span>" +
						"<span style='margin-left:5px; font-size: 12px; font-family: PingFang SC-Regular, PingFang SC; font-weight: 400; color: #4E5969;'>"
						+ params[1]['seriesName'] + "数</span></div>" +
						"<span style='font-size: 12px;font-family: PingFang SC-Regular, PingFang SC;font-weight: 400;color: #4E5969;'><span style='font-size: 14px; font-family: Helvetica Neue-Medium, Helvetica Neue; font-weight: 500; color: #1D2129;'><span style='font-size: 14px; font-family: Helvetica Neue-Medium, Helvetica Neue; font-weight: 500; color: #1D2129;''><span style='font-size: 14px; font-family: Helvetica Neue-Medium, Helvetica Neue; font-weight: 500; color: #1D2129;'>"
						+ params[1]['data'] + "</span>个</span></div>"
				}
				return res;

			},
			axisPointer: {
				type: 'shadow'
			},
			backgroundColor: "rgb(239, 242, 245,0.95)",
			borderColor: "rgb(239, 242, 245,0.95)",
			textStyle: {
				backgroundColor: 'red'
			},
		},
		legend: {
			data: ['按时完成', '未按时完成'],
			icon: 'circle',// legend 样式
			x: 'right',
			itemHeight: 13,
			itemWidth: 13,

		},
		toolbox: {
			show: true,
			orient: 'vertical',
			left: 'right',
			top: 'center',
			feature: {

			}
		},
		xAxis: [
			{
				type: 'category',
				axisTick: { show: false },
				data: xarray,
				axisLine: {
					lineStyle: {
						color: '#a4a7aa'
					}
				}
			}
		],
		yAxis: [
			{
				type: 'value',
				barWidth: '50%',
				name: '个',
				splitLine: {
					lineStyle: {
						type: 'dashed'//虚线
					},
					show: true //隐藏
				}
			}
		],
		series: [
			{
				name: '按时完成',
				type: 'bar',
				barWidth: '35px',
				barGap: 0,
				label: labelOption,

				itemStyle: {
					normal: {
						color: '#165DFF'
					},
				},

				emphasis: {
					focus: 'series'
				},
				data: donearray
			},
			{
				name: '未按时完成',
				type: 'bar',
				barWidth: '35px',
				barGap: 0,
				label: labelOption,
				itemStyle: {
					normal: {
						color: '#F53F3F',
						width: '20px',
						height: '20px',
					},
				},

				emphasis: {
					focus: 'series'
				},
				data: nodonearray
			},

		]
	};

	option && myChart.setOption(option);
}

//各型号计划数
function getXMplan(data) {

	console.log(data)

	let alldata = data;
	let thisdata = alldata[10]['data'];
	var xarray = [];
	var yarray = [];
	for (let i = 0; i < thisdata.length; i++) {
		xarray.push(thisdata[i]['key01'])
		yarray.push(thisdata[i]['key02'])
	}
	var chartDom = document.getElementById('modelplannumber');
	var myChart = echarts.init(chartDom);
	var option;

	option = {

		axisTick: {
			show: false,
		},

		tooltip: {
			show: true,
			trigger: 'axis',
			formatter: function (params) {
				for (var i = 0; i < params.length; i++) {
					var res = "<div style='margin-left:0px;margin-bottom:7px;padding:0;width:120px;height:24px;line-height:10px;border-radius:3px;font-size: 12px;font-weight: 500;color: #1D2129;'><p style='font-weight:500;'>"
						+ params[0]['axisValue'] +
						"</p></div>" +
						"<div style='display: flex; flex-direction: row; align-items: center; justify-content: space-between; margin-top:-10px; width:160px; background:white; height:30px;border-radius: 4px 4px 4px 4px; color: #fff;font-size: 14px; padding:0 12px;line-height: 10px'>" +
						"<div><span style='display:inline-block; border-radius:5px;   width:10px;height:10px;background-color:#165DFF;color:#1D2129;'></span>" +
						"<span style='margin-left:5px; font-size: 12px; font-family: PingFang SC-Regular, PingFang SC; font-weight: 400; color: #4E5969;'>预算执行率</span></div>" +
						"<span style='font-size: 12px;font-family: PingFang SC-Regular, PingFang SC;font-weight: 400;color: #4E5969;'><span style='font-size: 14px; font-family: Helvetica Neue-Medium, Helvetica Neue; font-weight: 500; color: #1D2129;'>"
						+ params[0]['data'] + "</span>个</span></div>"
				}
				return res;

			},
			axisPointer: {
				type: 'shadow'
			},
			backgroundColor: "rgb(239, 242, 245,0.95)",
			borderColor: "rgb(239, 242, 245,0.95)",
			textStyle: {
				backgroundColor: 'red'
			},
		},

		grid: {
			show: false,
			top: "50px",
			left: "40px",
			right: "10px",
			bottom: "43px"
		},
		xAxis: {
			type: 'value',
			boundaryGap: [0, 0.01],
			name: '个',
			splitLine: {
				lineStyle: {
					type: 'dashed'//虚线
				},
				show: true //隐藏
			},
			axisLine: {
				lineStyle: {
					color: '#a4a7aa'
				}
			}
		},
		yAxis: {
			type: 'category',
			data: xarray,
			"axisTick": {       //y轴刻度线
				"show": false,
			},
			splitLine: {
				lineStyle: {
					type: 'dashed'//虚线
				},
				show: false //隐藏
			},
			axisLine: {
				lineStyle: {
					color: '#a4a7aa'
				}
			}

		},
		series: [
			{
				itemStyle: {
					normal: {
						color: '#165DFF'
					},
				},
				barWidth: '20px',
				name: '2012',
				type: 'bar',
				//   data: [812, 712, 664, 620, 400,]
				data: yarray
			}
		]
	};
	option && myChart.setOption(option);
}

//阅读计划完成
function getMonPlanComplete(data) {

	let alldata = data;

	let totalnum = alldata[9].data[0].key01;
	let rate = alldata[7].data[0].key02;
	let thisdata = alldata[8].data;
	var realarray = [];
	for (var key in thisdata) {
		var param = {};
		// param.name= key;
		param.value = thisdata[key].key02;
		param.name = thisdata[key].key01;
		realarray.push(param);
	}

	///////////////////////////////////////////////
	var chartDom = document.getElementById('abcd');
	var myChart = echarts.init(chartDom);
	var option;
	let image;
	let imageColor;
	if (rate == 0) {
		image = 'assets/images/home/icon-pingjun@2x.png';
		imageColor = '#165DFF';
	} else if (rate < 0) {
		image = 'assets/images/home/arrow-down-filling.svg';
		imageColor = '#F53F3F'
	} else {
		image = 'assets/images/home/arrow-up-filling.svg';
		imageColor = '#00B42A'
	}

	option = {
		color: ['#165DFF', '#0FC6C2', '#50CD89', '#F1416C', '#FFC700', '#009EF7', '#7239EA'],
		title: {
			zlevel: 0,
			text: '{a|' + '计划总数' + '}\n{b|' + totalnum + '}\n',
			x: '19.2%',
			y: '42%',
			width: 140,
			textAlign: 'center',
			textStyle: {
				rich: {
					a: {
						fontSize: 12,
						color: '#86909C',
					},
					b: {
						fontSize: 24,
						color: '#1D2129',
						fontWeight: 600,
						lineHeight: 40
					},
					icon: {
						height: 16,
						width: 16,
						backgroundColor: {
							image: image,
						},
					},
					c: {
						fontSize: 12,
						color: imageColor,

					},
					d: {
						fontSize: 12,
						color: '#86909C',
					}
				}
			}
		},

		legend: {
			orient: 'vertical',
			x: 'left',
			y: 'center',
			itemGap: 30,
			height: '60%',
			width: '60%',
			left: '45%',
			itemHeight: 50,
			itemWidth: 5,
			formatter: function (name) {
				let target;
				for (let i = 0, l = alldata[8].data.length; i < l; i++) {
					if (alldata[8].data[i].key01 == name) {
						targett = alldata[8].data[i].key03 * 100;
						target = targett.toFixed(1)
					}
				}

				let arr = ['{a|' + name + '}{b|' + target + '} {c|%}'];
				return arr;
			},
			textStyle: {
				rich: {
					a: {
						fontSize: 12,
						verticalAlign: 'top',
						align: 'left',
						lineHeight: 19,
						padding: [6, 0, 0, 0],
						color: '#4E5969',
						width: '30%',
					},
					b: {
						fontSize: 17,
						align: 'right',
						padding: [30, 0, 0, -118],
						fontWeight: 600,
						color: '#1D2129',
					},
					c: {
						fontSize: 12,
						align: 'bottom',
						padding: [30, -225, 0, 0],
						color: '#86909C',
					},
				},
			}
		},
		animation: false,//禁用动画
		silent: true,//禁用点击echart的鼠标动画
		series: [
			{
				name: '计划总数',
				type: 'pie',
				radius: ['60%', '77%'],
				center: ['20%', '154px'],
				avoidLabelOverlap: false,
				itemStyle: {
					borderRadius: 0,
					borderColor: '#fff',
					borderWidth: 0
				},
				label: {
					show: false,
					position: 'center'
				},
				emphasis: {
					label: {
						show: false,
						fontSize: '40',
						fontWeight: 'bold'
					}
				},
				labelLine: {
					show: false
				},
				data: realarray
			}
		]
	};

	option && myChart.setOption(option);
}
function getMonPlanCompletee(data) {

	let alldata = data;

	let totalnum = alldata[9].data[0].key01;
	let rate = alldata[7].data[0].key02;
	let thisdata = alldata[8].data;
	var realarray = [];
	for (var key in thisdata) {
		var param = {};
		// param.name= key;
		param.value = thisdata[key].key02;
		param.name = thisdata[key].key01;
		realarray.push(param);
	}

	///////////////////////////////////////////////
	var chartDom = document.getElementById('abcdd');
	var myChart = echarts.init(chartDom);
	var option;
	let image;
	let imageColor;
	if (rate == 0) {
		image = 'assets/images/home/icon-pingjun@2x.png';
		imageColor = '#165DFF';
	} else if (rate < 0) {
		image = 'assets/images/home/arrow-down-filling.svg';
		imageColor = '#F53F3F'
	} else {
		image = 'assets/images/home/arrow-up-filling.svg';
		imageColor = '#00B42A'
	}

	option = {
		color: ['#165DFF', '#0FC6C2', '#50CD89', '#F1416C', '#FFC700', '#009EF7', '#7239EA'],
		title: {
			zlevel: 0,
			text: '{a|' + '计划总数' + '}\n{b|' + totalnum + '}\n',
			x: '19.2%',
			y: '42%',
			width: 140,
			textAlign: 'center',
			textStyle: {
				rich: {
					a: {
						fontSize: 12,
						color: '#86909C',
					},
					b: {
						fontSize: 24,
						color: '#1D2129',
						fontWeight: 600,
						lineHeight: 40
					},
					icon: {
						height: 16,
						width: 16,
						backgroundColor: {
							image: image,
						},
					},
					c: {
						fontSize: 12,
						color: imageColor,

					},
					d: {
						fontSize: 12,
						color: '#86909C',
					}
				}
			}
		},

		legend: {
			orient: 'horizontal',
			x: 'left',
			y: 'center',
			itemGap: 30,
			height: '60%',
			width: '50%',
			left: '47%',
			itemHeight: 50,
			itemWidth: 5,
			formatter: function (name) {
				let target;
				for (let i = 0, l = alldata[8].data.length; i < l; i++) {
					if (alldata[8].data[i].key01 == name) {
						targett = alldata[8].data[i].key03 * 100;
						target = targett.toFixed(1)
					}
				}

				let arr = ['{a|' + name + '}{b|' + target + '} {c|%}'];
				return arr;
			},
			textStyle: {
				rich: {
					a: {
						fontSize: 12,
						verticalAlign: 'top',
						align: 'left',
						lineHeight: 19,
						padding: [6, 0, 0, 0],
						color: '#4E5969',
						width: '30%',
					},
					b: {
						fontSize: 17,
						align: 'right',
						padding: [30, 0, 0, -118],
						fontWeight: 600,
						color: '#1D2129',
					},
					c: {
						fontSize: 12,
						align: 'bottom',
						padding: [30, -225, 0, 0],
						color: '#86909C',
					},
				},
			}
		},
		animation: false,//禁用动画
		silent: true,//禁用点击echart的鼠标动画
		series: [
			{
				name: '计划总数',
				type: 'pie',
				radius: ['50%', '67%'],
				center: ['20%', '154px'],
				avoidLabelOverlap: false,
				itemStyle: {
					borderRadius: 0,
					borderColor: '#fff',
					borderWidth: 0
				},
				label: {
					show: false,
					position: 'center'
				},
				emphasis: {
					label: {
						show: false,
						fontSize: '40',
						fontWeight: 'bold'
					}
				},
				labelLine: {
					show: false
				},
				data: realarray
			}
		]
	};

	option && myChart.setOption(option);
}


//////////////////////addEventListener/////////////////////////////////////
var myChart1 = echarts.init(document.getElementById('completedworkshop'));
var myChart2 = echarts.init(document.getElementById('abcd'));
var myChart3 = echarts.init(document.getElementById('modelplannumber'));
var myChart4 = echarts.init(document.getElementById('monthlycompletionprecent'));


window.addEventListener("resize", function () {
	myChart1.resize();
	myChart2.resize();
	myChart3.resize();
	myChart4.resize();
});